package crm.implementor;


import crm.daoInterfaces.ProductDao;
import crm.dbhandelling.Crude;
import crm.dto.Product;


public class ProductImp extends Crude implements ProductDao
{

	String className = new Product().getClass().getName();
	
	@Override
	public void add(Product prod) throws Exception 
	{
		super.insert(prod);
		
	}

	@Override
	public void update(Product prod) 
	{
		super.update(className, "productName", prod.getProductName(),"productCode", prod.getProductCode()+"");
		super.update(className, "status", prod.getStatus()+"","productCode", prod.getProductCode()+"");
	}

	@Override
	public void delete(Product prod) {
		super.delete(className, "productCode", prod.getProductCode()+"");
		
	}

	

	@Override
	public Product[] retrieveAll() throws Exception 
	{
		Object[] att=super.retreiveAll(className);
		Product[] p=new Product[att.length];
		for(int i=0;i<p.length;i++)
			p[i]=(Product) att[i];
	return p;
		
	}

	@Override
	public Product retrieve( String conditionField,
			String conditionValue) throws Exception 
	{
		Product p=(Product) super.retreive(className, conditionField, conditionValue);
		return p;
	}

	@Override
	public Product[] retrieveArray( String conditionField,
			String conditionValue) throws Exception 
	{
		Object[] att=super.retreiveArrayOnCondition(className, conditionField, conditionValue);
		Product[] s=new Product[att.length];
		for(int i=0;i<s.length;i++)
				s[i]=(Product) att[i];
		return s;
		
	}

	
}
